<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
<%@taglib prefix="spring" uri="http://www.springframework.org/tags" %>

<%String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title><jsp:include page="template.jsp"><jsp:param name="name" value="网站名称"/></jsp:include></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="icon" type="image/png" href='<jsp:include page="template.jsp"><jsp:param name="name" value="logo"/></jsp:include>'>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="<%=basePath%>resources/lib/layuiAdmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="<%=basePath%>resources/lib/layuiAdmin/style/admin.css" media="all">
    <link rel="stylesheet" href="<%=basePath%>resources/lib/layuiAdmin/style/login.css" media="all">
    <style>
    </style>
</head>
<body>
<div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="">

    <div class="layadmin-user-login-main">
        <div class="layadmin-user-login-box layadmin-user-login-header">
            <h2><jsp:include page="template.jsp"><jsp:param name="name" value="网站名称"/></jsp:include></h2>
        </div>
        <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-username" for="LAY-user-login-username"></label>
                <input type="text" name="username" id="LAY-user-login-username" lay-verify="required" placeholder="请输入用户名" value="admin" class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-password"></label>
                <input type="password" name="password" id="LAY-user-login-password" lay-verify="required" placeholder="请输入密码" value="123456" class="layui-input">
            </div>
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-xs7">
                        <label class="layadmin-user-login-icon layui-icon layui-icon-vercode" for="LAY-user-login-vercode"></label>
                        <input type="text" name="vercode" id="LAY-user-login-vercode" lay-verify="required" placeholder="请输入验证码" class="layui-input">
                    </div>
                    <div class="layui-col-xs5">
                        <div style="margin-left: 10px;">
                            <img src="<%=basePath%>captcha/getCaptchaCode.action" class="layadmin-user-login-codeimg" id="LAY-user-get-vercode">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item" style="margin-bottom: 20px;">
            </div>
            <div class="layui-form-item">
                <button class="layui-btn layui-btn-fluid" lay-submit id="submit"  lay-filter="LAY-user-login-submit">登录</button>
            </div>
        </div>
    </div>



</div>

<script src="<%=basePath%>resources/lib/layuiAdmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '<%=basePath%>resources/lib/layuiAdmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index',"form"], function(){
        var $ = layui.$
            ,form = layui.form
            ,router = layui.router();

        form.render();
        document.onkeyup = function (e) {
            var code = e.charCode || e.keyCode;
          if (code == 13) {
           $("#submit").click();
        }}
        $("#LAY-user-get-vercode").on("click",function () {
            $(this).attr("src","<%=basePath%>captcha/getCaptchaCode.action");
        })

        //提交
        form.on('submit(LAY-user-login-submit)', function(obj){
            layer.msg('登录中 ...', {icon: 16,shade: 0.01});
            $.ajax({
                url: "<%=basePath%>sso/login.action",
                type:"post",
                data:obj.field,
                dataType:"JSON",
                success:function (data) {
                    if (data.success){
                        layer.msg('登录成功', {
                            offset: '15px'
                            ,icon: 1
                            ,time: 1000
                        }, function(){
                            location.href = '../'; //后台主页
                        });
                    }else {
                        layer.msg(data.data);
                    }



                }
            });

        });

    });

</script>
</body>
</html>
